<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>计算属性的getter和setter</title>
    <script src="/js/vue.js"></script>
</head>

<body>
    <div id ="app">
        <p>{{}}</p>
    </div>

    <script>
     let app = new Vue({
        el: '#app',
        data: {
            firstName:'Shane',
            lastName:'He'
        },
        computed:{
            fullName(){     
                console.log('调用get方法');
                return this.lastName + " " + this.firstName
            },
            set(newValue){
                names = newValue.slpit(" ")
                console.log('调用set方法',names);
                this.firstName = names[1]
                this.lastName = names[0]
            }
        }
     });
    </script>
</body>

</html>